package com.lex.cheeseStrip.ui;

import android.os.Bundle;
import android.os.Handler;
import android.widget.ListView;

import com.andview.refreshview.XRefreshView;
import com.dh.cheesestrip.Util.AndroidUtil;
import com.dh.cheesestrip.Widget.ListViewInScrollView;
import com.lex.cheeseStrip.R;
import com.lex.cheeseStrip.adapter.Adapter;
import com.lex.cheeseStrip.app.BaseAct;

import butterknife.BindView;

public class RefreshAct extends BaseAct {

    @BindView(R.id.lv)
    ListViewInScrollView lv;

    @BindView(R.id.refreshView)
    XRefreshView refreshView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_refresh);
        init(this);

        refreshView.setPullLoadEnable(true);//允许上拉加载
        refreshView.setAutoLoadMore(false);//关闭自动加载
        refreshView.setXRefreshViewListener(new XRefreshView.SimpleXRefreshListener(){//上拉下拉监听事件
            @Override
            public void onRefresh() {
                super.onRefresh();
                AndroidUtil.toast("正在刷新");
                refreshView.stopRefresh();//停止刷新动画
            }

            @Override
            public void onLoadMore(boolean isSilence) {
                super.onLoadMore(isSilence);
                AndroidUtil.toast("正在加载");

                refreshView.stopLoadMore();//停止加载动画
            }
        });

        Adapter simpleAdapter = new Adapter(getActivity());
        lv.setAdapter(simpleAdapter);
        lv.setFocusable(false);//scrollview嵌套listview防止自动滚动
    }


}
